package com.mytest;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Test6 {

    public static void main(String[] args) {

        int [] array = {1,2,3,4,5,6,78,8,7,6,5,4,3,2,1};

        Arrays.sort(array);
        int max = array[array.length -1];
        int count = 1;
        for(int i = array.length -2;i > 0;i--){
            if(array[i] == max){
                count ++;
            }else {
                break;
            }
        }

        int left = 0;
        int right = array.length -1;
//        int max = 0;
//        int count = 0;
        while(left <= right){
            if(array[left] == array[right]){
                if(max < array[left]){
                    count = 0;
                    max = array[left];
                    count ++;
                }
            }else if (array[left] < array[right]){

            }else if (array[left] > array[right]){

            }
            left ++ ;
            right --;
        }
    }

    public void findNode(Node node){
        Set<Node> set = new HashSet<>();
        while(node != null){
            set.add(node);
            if(!node.equals(node.next) && set.contains(node.next)){
                set.remove(node.next);
            }
        }
        for(Node node1: set){
            //循环输出，不被其他node指向的node
            System.out.println(node1.index);


        }
    }

    class Node{

        int index;
        Node next;
        public Node(int index) {
            this.index = index;
        }
    }
}
